<template>
  <div class="login-container">
    <el-form
      v-show="true"
      :model="formdata"
      :rules="formrules"
      ref="LoginForm"
      label-position="left"
      label-width="0px"
      class="demo-ruleForm"
    >
      <h3 class="title">系统登录</h3>
      <el-form-item prop="userMobile">
        <el-input type="text" v-model="formdata.userMobile" placeholder="账号/手机号"></el-input>
      </el-form-item>
      <el-form-item prop="userPassword">
        <el-input type="password" v-model="formdata.userPassword" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item style="width:100%;">
        <el-button
          type="primary"
          style="width:100%;"
          native-type="submit"
          @click.native.prevent="handleLogin()"
          :loading="logining"
        >登录</el-button>
      </el-form-item>
      <span><a href="#/register">注册</a></span>
    </el-form>
  </div>
</template>

<script>
import constantRouterMap from "@/router";

export default {
  components: {
    
  },
  data() {
    return {
      logining: false,
      formdata: {
        userMobile: "",
        userPassword: "",
      },
      formrules: {
        userMobile: [{ required: true, message: "请输入账号", trigger: "blur" }],
        userPassword: [{ required: true, message: "请输入密码", trigger: "blur" }]
      },
    };
  },
  methods: {
    handleLogin() {
      this.$refs["LoginForm"].validate(valid => {
        if (valid) {
          this.logining = true;
          this.$store
            .dispatch("Login", this.formdata)
            .then(() => {
              this.$router.push({ path: "/mydesktop" });
              this.logining = false;
            })
            .catch(() => {
              this.logining = false;
            });
        } else {
          return false;
        }
      });
    },
  }
};
</script>

<style lang="scss" scoped>
.login-container {
  -webkit-border-radius: 5px;
  border-radius: 5px;
  -moz-border-radius: 5px;
  background-clip: padding-box;
  margin: 180px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;

  .login-form {
    position: absolute;
    left: 0;
    right: 0;
    width: 525px;
    padding: 25px 65px 25px 65px;
    margin: 120px auto;
    background: rgba(238, 239, 245, 0.94);
    border-radius: 15px;
  }

  .title {
    margin: 0px auto 40px auto;
    text-align: center;
    color: #505458;
  }

  .veri-box {
    background: red;
    cursor: pointer;
    width: 85%;
    height: 47px;
    float: right;
  }
}
</style>
